﻿using LY.DataAccess.Repository;
using LY.Entity;
using LY.Entity.Entities;
using LY.Entity.PageSearch;
using LY.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LY.Business.ServiceImpl
{
    public class DeptService : IDeptService
    {
        DeptRepository _repo;
        public DeptService()
        {
            _repo = new DeptRepository(); 
        }
        /// <summary>
        /// 部门列表
        /// </summary>
        /// <param name="view"></param>
        /// <returns></returns>
        public PagedList<S_Dept> QueryDeptList(PageView view)
        {
            return _repo.QueryDeptList(view);
        }
/// <summary>
        /// 部门列表
        /// </summary>
        /// <param name="view"></param>
        /// <returns></returns>
        public PagedList<LY.Entity.Entities.S_Dept_EX> QueryDeptEXList(PageView view)
        {
            return _repo.QueryDeptEXList(view);
        }
       //public string GetDeptNo() 
       //{
       //    return _repo.GetDeptNo();
       //}

       /// <summary>
       /// 保存项目信息
       /// </summary>
       /// <param name="inves"></param>
       /// <returns></returns>
        public int SaveDept(S_Dept dept)
       {
           if (dept.ID <= 0)
           {
               //新增
               return (int)_repo.Insert(dept);
           }
           else
           {
               //编辑
               return (int)_repo.Update(dept);
           }
       }

       /// <summary>
       /// 删除部门信息
       /// </summary>
       /// <param name="id"></param>
       /// <returns></returns>
       public int DeleteDept(int id)
       {
           return _repo.DeleteDept(id);
       }

       /// <summary>
       /// 检索部门信息
       /// </summary>
       /// <param name="id"></param>
       /// <returns></returns>
       public S_Dept GetDept(int? id)
       {
           return _repo.GetDept(id);
       }

       public List<S_Dept> GetDeptList()
       {
           return _repo.GetDeptList();
       }

        //查询部门的编号是否已经存在
        public int SelectCodeCount(int id, string code)
        {
            return _repo.SelectCodeCount(id,code);
        }

       
       
    }
}
